<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="domain.Recommendation"%>
<%@page import="business.BusinessRecommendation"%>
<%@page import="business.BusinessUser"%>
<%@page import="java.lang.reflect.Array"%>
<%@page import="business.BusinessMovie"%>
<%@page import="domain.Movie"%>
<%@page import="domain.Video"%>
<%@page import="business.BusinessVideo"%>
<%@page import="business.BusinessMovie"%>
<%@ page language="java" import="domain.User,java.util.*"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PelSer | Series</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- Stylesheets -->
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/input.css" />
	
<!-- Scripts -->
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/input.js"></script>
<!-- Scripts -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.roundabout-1.0.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>

<!--[if IE 6]>
	<script src="js/DD_belatedPNG_0.0.8a-min.js"></script>
	<script>
	  /* EXAMPLE */
	  DD_belatedPNG.fix('.button');
	  
	  /* string argument can be any CSS selector */
	  /* .png_bg example is unnecessary */
	  /* change it to what suits you! */
	</script>
	<![endif]-->
</head>
<body>
<div id="wrapper" class="container_12 clearfix">

<!-- Text Logo -->
<h1 id="logo" class="grid_4"><a href="index.jsp">PelSer</a></h1>
			<div>
			<!-- Navigation Menu -->
			<ul id="navigation" class="grid_8">
			<li><a href="films.jsp"><span class="meta">Tus Peliculas</span><br />Top</a></li>
			<li><a href="messages.html"><span class="meta">Tus
			mensajes</span><br />Mensajes</a></li>
			<li><a href="friends.jsp"><span class="meta">Tus Amigos</span><br />Amigos</a></li>
			<li><a href="profile.jsp"><span class="meta">Tu perfil</span><br />Perfil</a></li>
			<li><a href="wall.jsp" class="current"><span class="meta">Novedades</span><br />Muro</a></li>
			</ul>
			</div>
			<div>
        	<table width="100%">
        	<tr>
        		<td>
        		<form action="FrontControllerSearch" method="post">
        		<label class="input">
    			<span>Buscar...</span>
    			<input type="text"  name="busquedaSimple"/>
				</label>
        		<input type="hidden" name="rdtema" value="buscarSimple"/>
				<a href="search.jsp">Busqueda Avanzada</a>
				</form>
				</td>
        	 	<% if(session.getAttribute("session.user")!=null){
        	 		User usuario= (User)(session.getAttribute("session.user"));
        	 	%>
        	 	<td align="right">
        	 	<form action="FrontControllerLogin?accion=logout" method="post">
        	 	<input type="image" title="Salir" src="images/logout.gif" ondblclick="this.form.submit()"></input>
        	 	</form>
        	 	 
        	 	<% 
        	 	out.print("<i>Bienvenid@: <b>"+usuario.getName()+" "+usuario.getSurname()+"</b></i>");
        	 	} %>
        	 	</td>
        	</tr>
        	</table>
        </div>
		<%
			User user = (User) session.getAttribute("session.user");
			List<User> friends = new ArrayList<User>();
			for (Integer i : user.getFriends()) {
				User user2 = BusinessUser.getUserById(i);
				Video video = BusinessVideo.getVideoById(new Integer(request.getParameter("idVideo")));
				if (!(user2.getVideos().contains(video.getIdVideo()))) {					
					friends.add(BusinessUser.getUserById(i));
				}
			}
		%>
		<form action = "RecomendationController?idVideo=<% out.print(request.getParameter("idVideo"));%>" method="post">	
		
		
				<!-- Section 3 -->
				<div class="catagory_1 clearfix">
					<!-- Row 1 -->
					<div class="grid_3 textright" >
					
					
					<input type = "submit" value = "Recomendar" class = "button"  ></input>
					
					<!--  	<div class="hr clearfix dotted">&nbsp;</div>-->
					<h6>Comentario</h6>
					<textarea rows="6" cols="15" name = "Descripcion"></textarea>
					</div>
					<div class="grid_9">
					<table>
					<%
					for(User use : friends){
						%>
						<tr>
						<%
						if(BusinessRecommendation.noRecommmendation(new Integer(request.getParameter("idVideo")), use.getIdUser())!=null){ 
							%>
							<input type = "checkbox" name = "friends" disabled="disabled" value = <% out.print(use.getIdUser());%> ></input>
							<%
						}else{
						%>
							<input type = "checkbox" name = "friends" value = <% out.print(use.getIdUser());%> ></input>
						<%
						}
						out.print(use.getName() +" " + use.getSurname() +" (" +use.getLogin()+ ")"); 
						request.setAttribute("login", use.getLogin());
						%>
						</tr>	
					<%
					}	
					%>
					</table>
					</div>
					</div>
		</form>
</body>
</html>